//
//  ViewController.m
//  UI06_UIScorllView_相册
//
//  Created by LGC on 16/3/16.
//  Copyright © 2016年 Apon. All rights reserved.
//

/** 全图的宽 */
#define WIDTH self.view.frame.size.width

/** 全图的高 */
#define HEIGHT self.view.frame.size.height

#import "ViewController.h"
#import "MyScrollView.h"
#import "Album.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
//    [self createScrollView];
    [self createAlbum];
    // Do any additional setup after loading the view, typically from a nib.
}

#pragma mark - Data 
/** 数组数据 */
- (NSArray *)handleData {
    
    NSMutableArray *array = [NSMutableArray array];
    UIImage *LastImage = [UIImage imageNamed:[NSString stringWithFormat:@"pie_04.jpg"]];
    [array addObject:LastImage];
    /** 将图片添加到图片数组 */
    for (NSInteger i = 0; i < 5; i++) {
        
        NSString *name = [NSString stringWithFormat:@"pie_%02ld.jpg", i];
        
        UIImage *image = [UIImage imageNamed:name];
        
        [array addObject:image];
    }
    UIImage *firstImage = [UIImage imageNamed:[NSString stringWithFormat:@"pie_00.jpg"]];
    [array addObject:firstImage];
    /** 返回一个图片数组 */
    return array;
}

#pragma mark - 知识点1:UIScrollView

/** 添加汤姆猫图片的scrollView */
- (void)createScrollView {
    
    /** 接收图片数组数据 */
    NSArray *images = [self handleData];
    
    /** 一个全图大小的汤姆猫scrollView */
    MyScrollView *scroll = [[MyScrollView alloc]initWithFrame:CGRectMake(0, 0, WIDTH / 2.5, HEIGHT / 2.5) withImages:images];
    
    scroll.center = self.view.center;
    
    [self.view addSubview:scroll];
    /** -1 */
    [scroll release];
}


#pragma mark - 知识点2:相册(scrollView结合PageControll使用)

- (void)createAlbum {
    
    Album *album = [[Album alloc]initWithFrame:CGRectMake(0, 0, WIDTH / 1.5, HEIGHT / 1.5) withImages:[self handleData]];
    
    album.center = self.view.center;
    
    [self.view addSubview:album];
    
    [album release];
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
